import axios from 'axios';

export function request(config) {
  const instance = axios.create({
    baseURL: 'http://1.14.239.98/api/v2',
    timeout: 6800,
  });

  instance.interceptors.request.use((config) => {
    const token = localStorage.getItem('token');
    if (token) config.headers.Authorization = `Bearer ${token}`;
    return config;
  });

  instance.interceptors.response.use((res) => (res.data ? res.data : res));

  return instance(config);
}
